<template>
	<view class="Recharge_content Transfer_content">
		<view class="kuang">
			<view class="title">
				<view class="inline-block left">
					<image src="../../static/image/left.png" mode="" @tap="back"></image>
				</view>
				<view class="inline-block titleText" style="margin-left: 214upx;">
					{{symbol}}
				</view>
			</view>
			
			<view class="conin_info">
				<image :src="titleimg"></image>
				<view class="conin_info_detail">
					<text class="text_title">{{i18n.text_title}}</text>
					<text class="coin_number">{{amount}}<text></text>{{symbol}}</text>
					<!-- <view class="usdt">≈12.344657566 USTD</view> -->
				</view>
			</view>
			
			
			<view class="candidate">
				<text>{{i18n.candidatedetail}}</text>
			</view>
			<scroll-view scroll-y="true" class="data_list conin_lis"
			@scrolltoupper="upper" @scrolltolower="lower" @scroll="scroll"
			>
				<view class="datalis" v-if="this.list.length >0">
					<view class="item "
					 v-for="(item,index) in list" :key="index"
					  :class="{'out_icon':item.txto != accountName, 'in_icon':item.txto == accountName}"
					 >
						<view class="item_detail">
							<view class="detail_left coin_out">
								<image :src="item.txto == accountName?'../../static/image/in_icon.png':'../../static/image/out_icon.png' "></image>
								<view class="left_right">
									<view class="out_time">{{getTime(item.transactiontime)}}</view>
									<view class="coin_type">{{item.txto == accountName?i18n.zr:i18n.zc}}</view>
								</view>
							</view>
							<view class="item_rigth">
								<view class="out_r_t">{{item.txto == accountName?"+":"-"}}{{item.actiondata.realvalue}}</view>
								<view class="out_r_b">{{item.txto == accountName ? 'From：' + item.txfrom :'To：' + item.txto}}</view>
							</view>
						</view>
					</view>
				</view>
				<view v-else class="nodata">{{i18n.wzc}}</view>
				
				
			</scroll-view>
			
			<view class="coin_edit">
				<image :src="i18n.coin_edit1" @tap="out_coin"></image>
				<image :src="i18n.coin_edit2" @tap="in_coin"></image>
			</view>
			
		</view>


	</view>
</template>

<script>
	import account from '../../common/account.js'
	import {myMixins} from '../../common/mixins.js'
	export default {
		computed: {
			i18n() {
				return this.$t('user')
			}
		},
		mixins: [myMixins], // 使用mixin
		data() {
			return {
				assetName:"",
				assetId:"",
				symbol:"",
				decimals:"",
				amount:"",
				accountName:"",
				list:[],
				titleimg:""
			}
		},
		onLoad(options) {
			//console.log(options)
			var _this=this
			this.assetName = options.assetName;
			this.symbol = options.symbol.toUpperCase();
			this.assetId = options.assetId;
				if(this.assetId==0){
					_this.titleimg="../../static/image/icon_detail.png"
				}else{
					_this.titleimg="../../static/image/greylogo.png"
				}
			this.amount = Number(options.amount);
			this.accountName = this.account_info.accountName;
			this.decimals = options.decimals;
			//交易信息
			this.getList();
			uni.showLoading();
		},
		methods: {
			getTime(time){
				//转化时间戳
				time = Number(time.toString().substring(0,13))
				return this.$CommonJS.getTime(time,1)
			},
			getList(){
				//交易信息
				const _this = this;
				uni.request({
					url:this.$API.appServeApi + this.$API.gettransactionforbyassetid + '?i18n_language=' + uni.getStorageSync('system_info'),
					data:{
						account:this.accountName,
						assetid:this.assetId
					},
					success(res) {
						//console.log(res)
						uni.hideLoading()
						if(res.data.code == 200 && res.data.data.length >0){
							res.data.data.map(item =>{
								item.actiondata = JSON.parse(item.actiondata)
							})
							_this.list = res.data.data;
							//console.log(_this.list)
						}else{
							//_this.$CommonJS.showToast(res.data.message)
						}
					},
					fail(e) {
						//console.log(e)
						uni.hideLoading()
						_this.$CommonJS.showToast(e)
					}
				})
			},
			back(){
				this.$CommonJS.navigateBack()
			},
			upper: function(e) {
					console.log(e)
			},
			lower: function(e) {
					console.log(e)
			},
			scroll: function(e) {
					console.log(e)
					//this.old.scrollTop = e.detail.scrollTop
			},
			out_coin(){
				this.$CommonJS.navigateTo('./coin_out?assetId='+this.assetId+'&symbol='+this.symbol+'&amount='+this.amount + '&decimals=' + this.decimals)
			},
			in_coin(){
				this.$CommonJS.navigateTo('./coin_in?assetId='+this.assetId+'&symbol='+this.symbol+'&amount='+this.amount + '&assetName=' + this.assetName)
			},
		}
	}
</script>

<style lang="stylus">
	@import "../../static/stylus/wallet/wallet.stylus"
</style>
